-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Go: Add helper predicate lookThroughPointerType
#17792
Conversation
go/ql/lib/semmle/go/Types.qll
Outdated
@@ -489,8 +485,7 @@ class StructType extends @structtype, CompositeType { | |||
*/ | |||
private predicate hasEmbeddedField(Type tp, int depth) { | |||
exists(Field f | this.hasFieldCand(_, f, depth, true) | | |||
tp = f.getType() or | |||
tp = f.getType().(PointerType).getBaseType() | |||
tp = lookThroughPointerType(f.getType()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note this one may change behaviour, since tp
would have had multiple values before (unlike all of the others, where the type of tp
is disjoint with PointerType
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, that's a mistake. I consciously skipped some other cases like that. I'll revert this one.
Here is the RA for it on a random db (
The performance impact seems absolutely miniscule. I think this is ready to merge. I'm happy to do another DCA or even QA if there is any chance that it might affect performance or alerts. |
I got fed up of the extra boilerplate code needed to do this in various different situations. Performance-wise I'm not sure if it's better to mark this
pragma[inline]
or if it would be better to leave it as it is. (Or evenpragma[noinline]
!) I will make sure to fix any performance problems before merging.I'm open to suggestions for a better predicate name.